package com.person.leetcode.editor.cn;

import sun.reflect.generics.tree.Tree;

/**
  * 101.对称二叉树
  * 2022-05-16 17:17:35
**/
public class Sequence_0101_SymmetricTree {
    public static void main(String[] args) {
        Solution solution = new Sequence_0101_SymmetricTree().new Solution();
    }
    //leetcode submit region begin(Prohibit modification and deletion)
/**
  Definition for a binary tree node.

  public class TreeNode {
      int val;
      TreeNode left;
      TreeNode right;
      TreeNode() {}
      TreeNode(int val) { this.val = val; }
      TreeNode(int val, TreeNode left, TreeNode right) {
          this.val = val;
          this.left = left;
          this.right = right;
      }
  }
 **/

class Solution {
    public boolean isSymmetric(TreeNode root) {
        StringBuilder leftStr=new StringBuilder();
        StringBuilder rightStr=new StringBuilder();
        left(root.left,leftStr);
        right(root.right,rightStr);

        if (leftStr.toString().equals(rightStr.toString()) ){
            return true;
        }else{
            return false;
        }
    }

    public TreeNode left(TreeNode t,StringBuilder str){
        if (t == null){
            str.append("-111 ");
        }else{
            str.append(" ");
            str.append(t.val);
            left(t.left,str);
            left(t.right,str);
        }

        return null;
    }
    public TreeNode right(TreeNode t,StringBuilder str){
        if (t == null){
            str.append("-111 ");
        }else{
            str.append(" ");
            str.append(t.val);
            right(t.right,str);
            right(t.left,str);
        }
        return null;
    }



}
//leetcode submit region end(Prohibit modification and deletion)

}
